package com.it.tydic.estate.module.controller.xqgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;

import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.model.inner.Guanlichu;

import com.it.tydic.estate.module.service.XqglService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 房管处
 */
@RestController
@RequestMapping("xqgl")
@Api(tags="小区管理")
public class XqglController {
    @Autowired
    private XqglService xqglService;

    private static final Logger logger = LoggerFactory.getLogger(LouyuController.class);

    /**
     * 条件查询
     *
     * @param guanlichu 房管处对象
     * @return
     */
    @PostMapping("query")
    @ApiOperation(value = "条件查小区信息", notes = "条件查小区信息")
    public Result queryList(@RequestBody Map<String, Object> guanlichu) {
        logger.info("sucess");
        return xqglService.queryList(guanlichu);
    }

    /**
     * 新增或修改
     *
     * @param guanlichu 房管处对象
     * @return
     */
    @PostMapping("/addOrUpload")
    @ApiOperation(value = "小区添加或修改", notes = "小区添加或修改")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    public Result addOrUpload(@RequestBody Guanlichu guanlichu) {

        logger.info("sucess");
        return xqglService.addOrUpload(guanlichu);
    }

    /**
     * 根据主键删除小区
     *
     * @param id 主键
     * @return
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "根据主键删除小区", notes = "根据主键删除小区")
    public Result deleteById(@PathVariable String id) {

        logger.info("sucess");
        return xqglService.deleteById(id);
    }

    /**
     * 批量删除
     *
     * @param list 主键集合
     * @return
     */
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "批量删除", notes = "批量删除")
    @ControllerDesc(description = LogConstants.delete_data)
    public Result deleteBatch(@RequestBody List<String> list) {

        logger.info("sucess");
        return xqglService.deleteBatch(list);
    }
    /**
     * 根据主键查询小区
     *
     * @return
     */
    @GetMapping("queryById{id}")
    @ApiOperation(value = "根据主键查询小区", notes = "根据主键查询小区")
    public Result queryById(@PathVariable String id) {
        return xqglService.queryById(id);
    }
    /**
     * 查询小区和小区所属楼宇
     *
     * @return
     */
    @GetMapping("queryTree")
    @ApiOperation(value = "查询小区和小区所属楼宇", notes = "查询小区和小区所属楼宇")
    public Result queryTree() {
        return xqglService.queryTree();
    }

    /**
     * 查询小区
     * @return
     */
    @GetMapping("queryXqListt")
    @ApiOperation(value = "查询小区", notes = "查询小区")
    public Result queryXqListt() {
        return xqglService.queryXqListt();
    }
}
